package org.xwb.springcloud.messagetype.workqueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.xwb.springcloud.constant.MqConstant;

/**
 * 多个消费者绑定到一个队列，共同消费队列中的消息
 * @author 10564
 */
@Component
public class WorkQueueConsumer {
    private static final Logger log = LoggerFactory.getLogger(WorkQueueConsumer.class);

    /**
     * 消费者one监听队列，并接收消息
     * @param message 消息内容
     */
    @RabbitListener(queues = MqConstant.WORK_QUEUE_NAME)
    public void receiveWorkQueueMessageOne(String message) {
        log.info("\n工作队列消费者One接收消息:{}\n",message);
    }

    /**
     * 消费者two监听队列，并接收消息
     * @param message 消息内容
     */
    @RabbitListener(queues = MqConstant.WORK_QUEUE_NAME)
    public void receiveWorkQueueMessageTwo(String message) {
        log.info("\n工作队列消费者Two接收消息:{}\n",message);
    }
}
